function a(a, t, e) {
  return t in a ? Object.defineProperty(a, t, {
    value: e,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : a[t] = e, a;
}
var t, e = getApp();
var template = require('../../../../template/backstageTemplate.js');
Page({
  data: (t = {
      _num: 1,
      _num1: 0,
      show: !0,
      show1: !1,
      nav: 0,
      page: 0,
      page1: 0,
      prenumber: 6,
      prenumber1: 6,
      text: "",
      background: ["#cd5db8", "#f4b83e", "#5babf9", "#eb4c6f", "#59c387"],
      background1: ["#b75ad3", "#f2a83d", "#54acf9", "#ec608e", "#58c088"],
      wzshow: !1,
      wzshow1: !1,
      wrapBox: !0,
      h_type: 1,
    }, a(t, "wzshow", !1), a(t, "meiyou", !1), a(t, "meiyou1", !1), a(t, "forbidden", !0),
    t),
  particulars: function(a) {

    var h_id = a.currentTarget.dataset.h_id
    var h_leixing = a.currentTarget.dataset.h_leixing
    var h_type = this.data.h_type
    wx.setStorageSync("eduidindex", a.currentTarget.dataset.index + 1), wx.navigateTo({
      url: "/hyb_yl/backstageLife/pages/particulars/particulars?h_id=" + h_id + '&h_type=' + h_type
    });
  },
  share: function(a) {
    var that = this
    console.log(a)
    var arr = JSON.stringify(a.currentTarget.dataset.item)
    var zid = a.currentTarget.dataset.item.zid
    wx.navigateTo({
      url: "/hyb_yl/backstageLife/pages/publishFenx/publishFenx?fromType=2&patientType=3&saidtype=2" + '&hjlistinfo=' + arr + '&zid=' + zid
    });
  },
  jiagere: function(e) {
    var that = this
    console.log(e)
    var zid = that.data.zid
    var z_name = that.data.z_name
    var z_yy_sheng = e.currentTarget.dataset.z_yy_sheng

    wx.navigateTo({
      url: '/hyb_yl/backstageLife/pages/Dsaidnew/Dsaidnew?zid=' + zid + '&z_name=' + z_name,
    })
  },
  sharePublic: function(a) {
    var that = this
    var zid = that.data.zid
    wx.setStorageSync("currentSaid", this.data.arr1[a.currentTarget.dataset.index]),
      wx.navigateTo({
        url: "/hyb_yl/backstageLife/pages/publishSaid/publishSaid?fromType=2&patientType=3" + '&zid=' + zid
      });
  },
  clickNum: function(a) {
    var that = this;
    var zid = that.data.zid
    var leixin = a.currentTarget.dataset.num
    if (leixin == 2) {
      that.setData({
        h_type: 0
      })
      e.util.request({
        'url': 'entry/wxapp/Huanjiao.allhjfenl',
        data: {
          zid: zid
        },
        success: function(res) {
          console.log(res)
          var Wpost = res.data.fenl
          var hjlist = res.data.hjlist
          that.setData({
            Wpost: Wpost,
            hjlist: hjlist,
          })
        }
      })
    } else {
      this.getAllhjfenl()
    }
    that.setData({
      _num: a.target.dataset.num
    }), 1 == that.data._num ? (that.setData({
      show: !0,
      show1: !1,
      page: 0,
      meiyou1: !1
    }), that.onclick()) : 2 == that.data._num && (that.setData({
      show: !1,
      show1: !0,
      page1: 0,
      meiyou: !1
    }), that.onclick1());
    wx.hideNavigationBarLoading()
  },
  clickNum1: function(a) {
    var t = this;
    t.setData({
      h_type: 1
    })
    var hjlx = a.target.dataset.num
    if (hjlx == 1) {
      //查询热门患教
      e.util.request({
        'url': 'entry/wxapp/Huanjiao.remen',
        success: function(res) {
          console.log(res)
          var hjlist = res.data.hjlist
          for (var i = 0; i < hjlist.length; i++) {
            var num = hjlist[i].h_dianzan
            var num1 = hjlist[i].h_read
            var num2 = hjlist[i].h_zhuanfa
            if (num.length < 6) {
              hjlist[i].h_dianzan = num
            } else if (num.length > 8) {
              let decimal = num.substring(num.length - 8, num.length - 8);
              hjlist[i].h_dianzan = parseFloat(parseInt(num / 100000000) + '.' + decimal) + '亿';
            } else if (num.length > 5) {
              let decimal = num.substring(num.length - 4, num.length - 4)
              hjlist[i].h_dianzan = parseFloat(parseInt(num / 10000) + '.' + decimal) + 'W';
            }
            if (num1.length < 6) {
              hjlist[i].h_read = num1
            } else if (num1.length > 8) {
              let decimal = num1.substring(num1.length - 8, num1.length - 8);
              hjlist[i].h_read = parseFloat(parseInt(num1 / 100000000) + '.' + decimal) + '亿';
            } else if (num1.length > 5) {
              let decimal = num1.substring(num1.length - 4, num1.length - 4)
              hjlist[i].h_read = parseFloat(parseInt(num1 / 10000) + '.' + decimal) + 'w';
            }
            if (num2.length < 6) {
              hjlist[i].h_zhuanfa = num2
            } else if (num2.length > 8) {
              let decimal = num2.substring(num2.length - 8, num2.length - 8);
              hjlist[i].h_zhuanfa = parseFloat(parseInt(num2 / 100000000) + '.' + decimal) + '亿';
            } else if (num2.length > 5) {
              let decimal = num2.substring(num2.length - 4, num2.length - 4)
              hjlist[i].h_zhuanfa = parseFloat(parseInt(num2 / 10000) + '.' + decimal) + 'w';
            }
          }
          t.setData({
            hjlist: hjlist,
          })
        }
      })
    } else {

      this.getAllhjfenl()
    }
    t.setData({
      _num1: a.target.dataset.num
    }), 0 == t.data._num1 ? t.onclick1() : 1 == t.data._num1 && t.onclick1();
  },
  list: function(a) {
    var t = this;
    var id = a.target.dataset.id;
    var arrs = t.data.hjlist;
    var arry = [];
    if (id == "" || id == undefined) {
      t.setData({
        hjlist: arrs,
        nav: a.target.dataset.nav,
        text: a.target.dataset.id,
      })
    } else {
      arrs.map(function(obj) {
        console.log(obj)
        if (id == obj.h_flid) {
          arry.push(obj);
        }
      });
      t.setData({
        hjlist: arry,
        nav: a.target.dataset.nav,
        text: a.target.dataset.id,
      })
    }
  },
  dictionaries: function(a) {

  },
  onclick: function(a) {
    var t = this;
    var shuju = {
      eduId: 1,
      title: '预防感冒',
      name: '小花',
      releaseDayTime: '2018-10-23',
      nmType: '多吃蔬菜',
      pageView: 2,
      praiseNum: 10,
      shareNum: 5,
      coverImg: "/assets/images/wzzuan.png",
      eduType: 2
    };

    var shuju2 = {
      eduId: 1,
      title: '预防感冒和不运动',
      name: '小花',
      releaseDayTime: '2018-10-23',
      nmType: '多吃蔬菜',
      pageView: 3,
      praiseNum: 8,
      shareNum: 6,
      coverImg: "/assets/images/wzzuan.png",
      eduType: 2
    };
    var shuju1 = [shuju, shuju2, shuju, shuju2];
    var shuju3 = [shuju2, shuju, shuju2, shuju];
    t.setData({
      arr: shuju1
    });
    t.setData({
      arr1: shuju3
    })
  },
  onclick1: function(a) {

  },
  lower: function() {
    if (!this.data.meiyou1 && !this.data.closureFlag) {
      this.setData({
        closureFlag: !0
      });
      var a, t = this,
        o = this.data.page,
        s = t.data.arr;
      wx.request({
        url: e.globalData.dic + "doctor/education/doctorEducation/" + o + "/" + t.data.prenumber + "/" + t.data.token,
        data: {
          cdType: t.data.text
        },
        success: function(e) {
          if (console.log(e), 200 == e.data.code) {
            o++, t.setData({
              page: o
            });
            var n = e.data.data;
            if (a = s.concat(n), e.data.data.length == []) return t.setData({
              meiyou1: !0,
              closureFlag: !1
            }), !1;
            wx.showLoading({
              title: "加载中",
              icon: "loading"
            }), t.setData({
              arr: a,
              closureFlag: !1
            }), setTimeout(function() {
              wx.hideLoading();
            }, 1500);
          }
        }
      });
    }
  },
  lower1: function() {
    if (!this.data.meiyou && !this.data.closureFlag) {
      this.setData({
        closureFlag: !0
      });
      var a, t = this,
        o = t.data.page1,
        s = t.data.arr1;
      wx.request({
        url: e.globalData.dic + "doctor/education/listDoctorEducation/" + o + "/" + t.data.prenumber1,
        data: {
          type: t.data._num1
        },
        success: function(e) {
          if (console.log(e), 200 == e.data.code) {
            o++, t.setData({
              page1: o
            });
            var n = e.data.data;
            if (a = s.concat(n), e.data.data.length == []) return t.setData({
              meiyou: !0,
              closureFlag: !1
            }), !1;
            wx.showLoading({
              title: "加载中",
              icon: "loading"
            }), t.setData({
              arr1: a,
              closureFlag: !1
            }), setTimeout(function() {
              wx.hideLoading();
            }, 1500);
          }
        }
      });
    }
  },
  statistics: function(a) {

  },
  clicknav: function(a) {
    var hj_id = a.currentTarget.dataset.hj_id
    wx.navigateTo({
      url: "/hyb_yl/backstageServicess/pages/commonality/commonality?hj_id=" + hj_id
    });
  },
  onLoad: function(a) {
    template.tabbar("tabBar", 2, this);
    var t = this;
    this.getAllhjfenl()
    this.getMyzhuan()
    t.setData({
      token: wx.getStorageSync("log") || ""
    }), t.onclick(), t.onclick1(), t.dictionaries(), wx.getSystemInfo({
      success: function(a) {
        t.setData({
          height: a.windowHeight
        });
      }
    });
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
  },
  alet: function(a) {
    this.setData({
      showshow: !1
    });
  },
  wrapBox: function(a) {
    this.setData({
      showshow: !0
    });
  },
  onShow: function() {
    var taht = this
    let pages = getCurrentPages();
    let currPage = pages[pages.length - 1];
    if (currPage.data.type == 1) {
      this.getAllhjfenl()
    }
  },
  bindTouchStart: function(a) {
    this.startTime = a.timeStamp;
  },
  bindTouchEnd: function(a) {
    this.endTime = a.timeStamp;
  },
  longTap: function(a) {
    var t = this;
    wx.showActionSheet({
      itemList: ["删除宣教"],
      success: function(o) {
        wx.getStorageSync("log");
        var s = a.currentTarget.dataset.groupid;
        wx.request({
          url: e.globalData.dic + "doctor/education/deleteMyEducation/" + s,
          success: function(a) {
            console.log(a), t.onclick();
          }
        });
      }
    });
  },
  getAllhjfenl: function() {
    var that = this
    that.setData({
      h_type: 1
    })
    e.util.request({
      'url': 'entry/wxapp/Huanjiao.allhjfenl',
      success: function(res) {
        console.log(res)
        var Wpost = res.data.fenl
        var hjlist = res.data.hjlist
        for (var i = 0; i < hjlist.length; i++) {
          var num = hjlist[i].h_dianzan
          var num1 = hjlist[i].h_read
          var num2 = hjlist[i].h_zhuanfa
          if (num.length < 6) {
            hjlist[i].h_dianzan = num
          } else if (num.length > 8) {
            let decimal = num.substring(num.length - 8, num.length - 8);
            hjlist[i].h_dianzan = parseFloat(parseInt(num / 100000000) + '.' + decimal) + '亿';
          } else if (num.length > 5) {
            let decimal = num.substring(num.length - 4, num.length - 4)
            hjlist[i].h_dianzan = parseFloat(parseInt(num / 10000) + '.' + decimal) + 'W';
          }
          if (num1.length < 6) {
            hjlist[i].h_read = num1
          } else if (num1.length > 8) {
            let decimal = num1.substring(num1.length - 8, num1.length - 8);
            hjlist[i].h_read = parseFloat(parseInt(num1 / 100000000) + '.' + decimal) + '亿';
          } else if (num1.length > 5) {
            let decimal = num1.substring(num1.length - 4, num1.length - 4)
            hjlist[i].h_read = parseFloat(parseInt(num1 / 10000) + '.' + decimal) + 'w';
          }
          if (num2.length < 6) {
            hjlist[i].h_zhuanfa = num2
          } else if (num2.length > 8) {
            let decimal = num2.substring(num2.length - 8, num2.length - 8);
            hjlist[i].h_zhuanfa = parseFloat(parseInt(num2 / 100000000) + '.' + decimal) + '亿';
          } else if (num2.length > 5) {
            let decimal = num2.substring(num2.length - 4, num2.length - 4)
            hjlist[i].h_zhuanfa = parseFloat(parseInt(num2 / 10000) + '.' + decimal) + 'w';
          }
        }
        that.setData({
          Wpost: Wpost,
          hjlist: hjlist,
        })
      }
    })
  },
  getMyzhuan: function() {
    var that = this
    e.util.request({
      'url': 'entry/wxapp/Zhuanjia.ifzj',
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function(res) {
        console.log(res)
        that.setData({
          zid: res.data
        })
      },
      fail: function(err) {
        console.log(err)
      },
    })
  },

});